<?php
	require_once('security.php');
 
	/*if ((isset($_POST['submit']))) 
	{

		// Split filename string into array using "." separator
		$extension = explode ('.', $_FILES['upload']['name']);
		// Create new filename with original file extension added
		// modified by ljohns 31Aug08 original code not working missing file name
		// also added remove an extension if supplied to maintain integ of file type
		$newFileName = explode('.',$_POST['filename']);
		$filename = $newFileName[0] . '.' . $extension[1];
		$imageText = $_POST['imageText'];
	
		// Move the file from temp folder to images folder
		if (move_uploaded_file($_FILES['upload']['tmp_name'], "../imgtxt/$filename"))
		{
			$response = 'The file named <b>' . $filename . '</b> has been uploaded.';
			$display = '<br /><img src="../imgtxt/' . $filename . '" />';
			$displayImageText = '<br />The file named <b>' . $newFileName[0] . '.txt' . '</b> has been uploaded.';
	  
			$fh = fopen("../imgtxt/$newFileName[0].txt", "w");
	  
			fwrite($fh, $imageText);
	  
			fclose($fh);
	  
		}
		else
		{
			$response = 'The file could not be moved.';
		}
	}*/
?>

<?php $thisPage = "editTxt"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Edit a text files</title>
		<meta name="robots" content="noindex,nofollow" />
		<?php require_once('theme/admintheme.php');?>
	</head>
	<body>
		
		<div id="wrap">
		
		<?php include_once('navigation.php'); ?>
	
		<!--<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		
			Enter a text name to be edited (eg image.txt)<br />
			<input type="text" name="edit" id="edit" size="40" value="<?php if (isset($_POST['submit'])) echo $_POST['edit']; ?>" maxlength="60" />
			<br />			
			<input type="submit" name="submit" value="Edit Text Files" />	
			
		</form>-->

	<?php  
  
  
  echo "<h3>Existing text file</h3>";
  echo '<p><b>Edit text file in imgTxt folder:(click to edit)</b></p>';
  echo '<br />';
  
  $dirname1 = "../imgtxt";  
  
  $dh1 = opendir($dirname1);
  while (false !== ($file1 = readdir($dh1)))
  {
    if ((strstr($file1, '.txt')))
	{
      //print '<a href="../imgtxt/' . $file1 . '" title="ViewText">' . $file1 . '</a><br />';
	  print '<a href="txtFileToBeEdit.php?page=' . $file1 . '" title="Edit">' . $file1 . '</a><br />';
    }
  }
  closedir($dh1);
  
  /*echo '<h3>Existing files</h3>';

  echo '<div id="php">';
  echo '<p><b>CMS page files (click to edit):</b></p>';
  echo "\n<ul>\n";
  echo '<li><a href="write.php?page=index" title="Edit">index.php</a></li>';
  $dirname = "../";
  $dh = opendir($dirname);
  $filesArray1 = array();
  while (false !== ($file = readdir($dh))) {
    // Select .php files
    if (strstr($file, '.php')) {
      // Add each file to array
      $filesArray1[] = $file;
    }
  }
  // Sort alphabetically
  natcasesort($filesArray1);
  foreach ($filesArray1 as $file) {
    $edit_me = str_replace(".php", "", $file);
    print '<li><a href="write.php?page=' . $edit_me . '" title="Edit">' . $file . '</a></li>';
  }
  closedir($dh);
  echo "\n</ul>\n";
  echo '</div>';

  echo '<div id="txt">';
  echo '<p><b>Corresponding text files:</b></p>';
  echo "\n<ul>\n";
  echo '<li><a href="../textfiles/index.txt" title="View">index.txt</a></li>';
  $dirname = "../textfiles";
  $dh = opendir($dirname);
  $filesArray2 = array();
  while (false !== ($file = readdir($dh))) {
    // Select .txt files
    if (strstr($file, '.txt')) {
      // Add each file to array
      $filesArray2[] = $file;
    }
  }
  // Sort alphabetically
  natcasesort($filesArray2);
  foreach ($filesArray2 as $file) {
    if ($file !== 'index.txt') {
      print '<li><a href="../textfiles/' . $file . '" title="View">' . $file . '</a></li>';
    }
  }
  closedir($dh);
  echo "\n</ul>\n";
  echo '</div>';*/

	?>

		</div>
	</body>
</html>